import { Component, Input, OnInit } from '@angular/core';
import { AppGlobalService } from 'src/app/shared/service/app-global.service';
import { EventService } from 'src/app/shared/service/event.service';
@Component({
  selector: 'app-feng-wo-message',
  templateUrl: './feng-wo-message.component.html',
  styleUrls: ['./feng-wo-message.component.scss'],
})
export class FengWoMessageComponent implements OnInit {
  @Input() tagData: any;
  sessionId = localStorage.getItem('sessionId');
  constructor(
    private appGlobalService: AppGlobalService,
    private eventService: EventService,
  ) {
  }

  ngOnInit() {
    localStorage.setItem('needRefresh', 'true');
    localStorage.setItem('needRefreshTab2', 'true');
  }
  goPage(obj) {
    try {
      if (obj) {
        if (this.tagData.data.isNew) {
          this.tagData.data.isNew = false;
          localStorage.setItem("isUpdateMsgBadgeTag", "1");
          if (this.appGlobalService.clientType === 'js') {
            this.eventService.eventEmit.emit("updateMsgBadge", { tab2: -1, });
          } else {
            this.eventService.eventEmit.emit("updateMsgBadge", { tab3: -1, });
          }
        }

        const targetObj = { pageId: obj.target, params: {}, sessionId: localStorage.getItem('sessionId') };
        this.appGlobalService.goToForward(targetObj);
      }
    } catch (error) {
    }
  }

}
